home *** CD-ROM | disk | FTP | other *** search
/ Amiga Game-Power / Amiga Game-Power.iso / pd mix i / lha / owndevunit / source / odulibhead.a < prev    next >
Text File  |  1994-05-20  |  3KB  |  141 lines

  1.     SECTION NTRYHUNK,CODE
  2.  
  3.  NOLIST
  4.  INCLUDE "exec/types.i"
  5.  INCLUDE "exec/execbase.i"
  6.  INCLUDE "exec/libraries.i"
  7.  INCLUDE "exec/initializers.i"
  8.  INCLUDE "exec/resident.i"
  9.  LIST
  10.  
  11.  INCLUDE "ODUversion.i"
  12.  
  13.     XREF    _LinkerDB
  14.     XREF    __BSSBAS
  15.     XREF    __BSSLEN
  16.  
  17.     XREF    _LibInit
  18.     XREF    _LibOpen
  19.     XREF    _LibClose
  20.     XREF    _LibExpunge
  21.     XREF    _LockDevUnit
  22.     XREF    _AttemptDevUnit
  23.     XREF    _FreeDevUnit
  24.     XREF    _NameDevUnit
  25.     XREF    _AvailDevUnit
  26.     XREF    _RexxQuery
  27.  
  28. ; macro for calling routines in other libraries
  29. CALL    MACRO
  30.     XREF    _LVO\1
  31.     jsr    _LVO\1(a6)
  32.     ENDM
  33.  
  34. ; the first executable location sets an error and returns in case someone
  35. ; tries to load the library as a load moudle instead of OpenLibrary()ing it
  36.     moveq    #-1,d0
  37.     rts
  38.  
  39. ; the romtag structure for this library
  40. initDDescrip:
  41.         ;STRUCTURE RT,0
  42.     dc.w RTC_MATCHWORD    ; UWORD RT_MATCHWORD
  43.     dc.l initDDescrip    ; APTR  RT_MATCHTAG
  44.     dc.l EndCode        ; APTR  RT_ENDSKIP
  45.     dc.b RTF_AUTOINIT    ; UBYTE RT_FLAGS
  46.     dc.b VERSION        ; UBYTE RT_VERSION
  47.     dc.b NT_LIBRARY        ; UBYTE RT_TYPE
  48.     dc.b 0            ; BYTE  RT_PRI
  49.     dc.l ODUName        ; APTR  RT_NAME
  50.     dc.l idString        ; APTR  RT_IDSTRING
  51.     dc.l Init        ; APTR  RT_INIT
  52.  
  53. ; the name of the library
  54. ODUName: dc.b 'OwnDevUnit.library',0
  55.  
  56. ; text identifier tag for the library
  57.     ds.w 0    ; word align info string for programs like XOper...
  58. idString: dc.b 'OwnDevUnit.library v'
  59.       IDSTR
  60.       dc.b 13,10,'Copyright ',$a9,' 1991 by Christopher A. Wichura',13,10
  61.       dc.b 'All Rights Reserved.',13,10,0
  62.  
  63. ; word align everything
  64.     ds.w 0
  65.  
  66. ; this is the init structure that our RTF_AUTOINIT told exec to look for
  67. Init:
  68.     dc.l LIB_SIZE        ; size of library base data space
  69.     dc.l funcTable        ; pointer to the function initializers
  70.     dc.l dataTable        ; pointer to the data initializers
  71.     dc.l initRoutine    ; routine to run
  72.  
  73. ; here we have the function table.  it, of course, starts with the standard
  74. ; library routines like Open, etc.
  75. funcTable:
  76.     dc.l _LibOpen
  77.     dc.l _LibClose
  78.     dc.l _LibExpunge
  79.     dc.l Null        ; reserved routine
  80.  
  81. ; my library routines
  82.     dc.l _LockDevUnit
  83.     dc.l _AttemptDevUnit
  84.     dc.l _FreeDevUnit
  85.     dc.l _NameDevUnit
  86.     dc.l _AvailDevUnit
  87.     dc.l RexxDispatch        ; we call an asm stub to make
  88.                     ; returning an argstring easier
  89.  
  90. ; end of library function list
  91.     dc.l -1
  92.  
  93. ; static data structures initilization table
  94. dataTable:
  95.     INITBYTE LN_TYPE,NT_LIBRARY
  96.     INITLONG LN_NAME,ODUName
  97.     INITBYTE LIB_FLAGS,LIBF_SUMUSED|LIBF_CHANGED
  98.     INITWORD LIB_VERSION,VERSION
  99.     INITWORD LIB_REVISION,REVISION
  100.     INITLONG LIB_IDSTRING,idString
  101.     dc.l 0
  102.  
  103. ; after the library has been allocated this next routine gets called.
  104. ; d0 = library's pointer, a0 = segment list
  105. ;
  106. ; returning non-zero means ok to link library into system list
  107. initRoutine:
  108.     movem.l    a3/a5,-(sp)
  109.  
  110.     movem.l    d0/a0,-(sp)        ; save pointers
  111.  
  112. ; clear the BSS data area
  113.     lea    __BSSBAS,a3
  114.     moveq    #0,d1
  115.     move.l    #__BSSLEN,d0
  116.     bra.s    2$
  117. 1$    move.l    d1,(a3)+
  118. 2$    dbf    d0,1$
  119.  
  120. ; now call the init routine in the C code to handle any other stuff
  121.     movem.l    (sp)+,d0/a0
  122.     jsr    _LibInit
  123.  
  124. 4$:    movem.l    (sp)+,a3/a5
  125.     rts
  126.  
  127. Null:                ; Commodore reserved routine.  always
  128.     moveq    #0,d0        ; return NULL for now!
  129.     rts
  130.  
  131. RexxDispatch:
  132.     subq.l   #4,sp            ; Create temporary variable
  133.     move.l   sp,a1            ; load return pointer
  134.     jsr      _RexxQuery        ; D0 = error code
  135.     movea.l  (sp)+,a0        ; Result string
  136.     rts
  137.  
  138. EndCode:    ; maker for end of this code
  139.  
  140.     END
  141.